package com.xh.common.valid;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author 史建飞
 * @version 1.0
 */
public class PatternConstraintValidator implements ConstraintValidator<PatternValidate,Integer> {
    private String regexp;
    @Override
    public void initialize(PatternValidate constraintAnnotation) {
        regexp = constraintAnnotation.regexp();
    }

    @Override
    public boolean isValid(Integer value, ConstraintValidatorContext context) {
        return value.toString().matches(regexp);
    }
}
